const Router = require('koa-router')
const remove = new Router()
const db = require('../mysql/index');
const bodyparser = require("koa-body");
remove.use(bodyparser())
// var gamelist
//
// db.query(`SELECT game.G_NAME "gamename",game.G_COVER "url",game.G_DESC "gamedesc" FROM game`,function(result){
//     gamelist = result
// })

remove.post('/comment', async (ctx)=>{
    let id = ctx.request.body.commentid
    let sql = `DELETE FROM comments WHERE id = ${id}`
    console.log(sql)
    ctx.body = await new Promise((resolve, reject) => {
        return db.query(sql, [],(data) => {
            resolve('删除成功')
        })
    })
})

remove.post('/game', async (ctx)=>{
    let id = ctx.request.body.gameid
    let sql = `DELETE FROM game WHERE G_ID = ${id}`
    console.log(sql)
    ctx.body = await new Promise((resolve, reject) => {
        return db.query(sql, [],(data) => {
            resolve('删除成功')
        })
    })
})

module.exports = remove
